package pearson.automation.forms.registration;

import org.openqa.selenium.By;

import framework.BaseForm;
import framework.elements.Button;
import framework.elements.ComboBox;
import framework.elements.TextBox;

public class AccountInformationForm extends BaseForm {
    /*
     * Account info
     */
    private static ComboBox title = new ComboBox(
            By.name("person_title"), "Person title");
    private TextBox firstName = new TextBox(
            By.id("firstName"), "First name");
    private TextBox lastName = new TextBox(
            By.id("lastName"), "Last name");
    private TextBox email = new TextBox(
            By.id("emailAddy"), "Email");
    private TextBox emailConfirm = new TextBox(
            By.id("emailAddyConfirm"), "Email Confirm");

    /*
     * School info
     */
    private ComboBox schoolCountry = new ComboBox(
            By.id("entered_countryid"), "School country");
    private TextBox schoolName = new TextBox(
            By.id("otherSchoolName"), "School name");
    private TextBox schoolCity = new TextBox(
            By.id("otherSchoolCity"), "School city");

    /*
     * Additional account info
     */
    private ComboBox secretQuestion = new ComboBox(
            By.name("person_verifyquestionid"), "Secret question");
    private TextBox secretAnswer = new TextBox(
            By.name("person_verifyanswer"), "Secret answer");

    private Button next = new Button(
            By.id("next"), "Next");

    public AccountInformationForm() {
    super(title.getLocator(), "Account Information");
    }

    /**
     * Step3 of the registration.
     * @param personTitle - selector (Valid Mr.)
     * @param fName - first name
     * @param lName - last name
     * @param personEmail - user's email
     * @param schlCountry - Other!!!
     * @param schlName - GLOBAL
     * @param schlCity - smth
     * @param scrQuestion - dropdown values
     * @param scrAnswer - smth
     * @return new confirmation summary form
     */
    public final ConfirmationSummaryForm fillRegistrationData(
            final String personTitle, final String fName, final String lName,
            final String personEmail, final String schlCountry,
            final String schlName, final String schlCity,
            final String scrQuestion, final String scrAnswer) {
    info("Fill registration data on step No3");
    //fill personal data
    title.select(personTitle);
    firstName.type(fName);
    lastName.type(lName);
    email.type(personEmail);
    emailConfirm.type(personEmail);

    //fill school data
    schoolCountry.select(schlCountry);
    schoolName.type(schlName);
    schoolCity.type(schlCity);

    //fill additional data
    secretQuestion.select(scrQuestion);
    secretAnswer.type(scrAnswer);

    //loading next page
    next.clickAndWait();
    return new ConfirmationSummaryForm();
    }
}
